const TODOMVC = 'TODOMVC'
const BTNMVC = 'BTNMVC'

export let todoStorage = {
    fetch() {//获取
        return JSON.parse(localStorage.getItem(TODOMVC) || '[]')
    },
    save(todos) {   // 存储
        localStorage.setItem(TODOMVC, JSON.stringify(todos))
    }
}
export let btnStorage = {
    fetch() {//获取
        return localStorage.getItem(BTNMVC) || 'all'
    },
    save(btn) {   // 存储
        localStorage.setItem(BTNMVC, btn)
    }
}

export let filters = {
    all(todos) {
        return todos
    },
    active(todos) {
        return todos.filter((todo) => !todo.completed)
    },
    completed(todos) {
        return todos.filter((todo) => todo.completed)
    }
}